package o;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.view.ViewCompat;
import androidx.core.widget.TextViewCompat;
import androidx.legacy.widget.Space;
import com.google.android.material.textfield.TextInputLayout;
import java.util.ArrayList;
import java.util.List;
import o.aqu.c;
import o.aqu.j;

public final class asy {
    @Nullable
    private Animator ʻ;
    private Typeface ʻॱ;
    private final float ʼ = ((float) this.ॱ.getResources().getDimensionPixelSize(c.ॱᐝ));
    private int ʽ;
    private FrameLayout ˊ;
    private TextView ˊॱ;
    private final TextInputLayout ˋ;
    private CharSequence ˋॱ;
    private LinearLayout ˎ;
    private int ˏ;
    private boolean ˏॱ;
    private int ͺ;
    private final Context ॱ;
    private CharSequence ॱˊ;
    private boolean ॱˋ;
    private int ॱॱ;
    private int ॱᐝ;
    private int ᐝ;
    private TextView ᐝॱ;

    public asy(TextInputLayout textInputLayout) {
        this.ॱ = textInputLayout.getContext();
        this.ˋ = textInputLayout;
    }

    public void ˏ(CharSequence charSequence) {
        ˏ();
        this.ॱˊ = charSequence;
        this.ᐝॱ.setText(charSequence);
        if (this.ᐝ != 2) {
            this.ʽ = 2;
        }
        ˊ(this.ᐝ, this.ʽ, ˊ(this.ᐝॱ, charSequence));
    }

    void ˊ() {
        ˏ();
        if (this.ᐝ == 2) {
            this.ʽ = 0;
        }
        ˊ(this.ᐝ, this.ʽ, ˊ(this.ᐝॱ, null));
    }

    public void ˊ(CharSequence charSequence) {
        ˏ();
        this.ˋॱ = charSequence;
        this.ˊॱ.setText(charSequence);
        if (this.ᐝ != 1) {
            this.ʽ = 1;
        }
        ˊ(this.ᐝ, this.ʽ, ˊ(this.ˊॱ, charSequence));
    }

    public void ˎ() {
        this.ˋॱ = null;
        ˏ();
        if (this.ᐝ == 1) {
            if (!this.ॱˋ || TextUtils.isEmpty(this.ॱˊ)) {
                this.ʽ = 0;
            } else {
                this.ʽ = 2;
            }
        }
        ˊ(this.ᐝ, this.ʽ, ˊ(this.ˊॱ, null));
    }

    private boolean ˊ(TextView textView, @Nullable CharSequence charSequence) {
        return ViewCompat.ˊᐝ(this.ˋ) && this.ˋ.isEnabled() && !(this.ʽ == this.ᐝ && textView != null && TextUtils.equals(textView.getText(), charSequence));
    }

    private void ˊ(int i, int i2, boolean z) {
        if (z) {
            Animator animatorSet = new AnimatorSet();
            this.ʻ = animatorSet;
            List arrayList = new ArrayList();
            ˊ(arrayList, this.ॱˋ, this.ᐝॱ, 2, i, i2);
            ˊ(arrayList, this.ˏॱ, this.ˊॱ, 1, i, i2);
            aqs.ˏ(animatorSet, arrayList);
            final TextView ˋ = ˋ(i);
            final TextView ˋ2 = ˋ(i2);
            final int i3 = i2;
            final int i4 = i;
            animatorSet.addListener(new AnimatorListenerAdapter(this) {
                final /* synthetic */ asy ˎ;

                public void onAnimationEnd(Animator animator) {
                    this.ˎ.ᐝ = i3;
                    this.ˎ.ʻ = null;
                    if (ˋ != null) {
                        ˋ.setVisibility(4);
                        if (i4 == 1 && this.ˎ.ˊॱ != null) {
                            this.ˎ.ˊॱ.setText(null);
                        }
                    }
                }

                public void onAnimationStart(Animator animator) {
                    if (ˋ2 != null) {
                        ˋ2.setVisibility(0);
                    }
                }
            });
            animatorSet.start();
        } else {
            ˏ(i, i2);
        }
        this.ˋ.ʽ();
        this.ˋ.ॱ(z);
        this.ˋ.ʼ();
    }

    private void ˏ(int i, int i2) {
        if (i != i2) {
            TextView ˋ;
            if (i2 != 0) {
                ˋ = ˋ(i2);
                if (ˋ != null) {
                    ˋ.setVisibility(0);
                    ˋ.setAlpha(1.0f);
                }
            }
            if (i != 0) {
                ˋ = ˋ(i);
                if (ˋ != null) {
                    ˋ.setVisibility(4);
                    if (i == 1) {
                        ˋ.setText(null);
                    }
                }
            }
            this.ᐝ = i2;
        }
    }

    private void ˊ(List<Animator> list, boolean z, TextView textView, int i, int i2, int i3) {
        if (textView != null && z) {
            if (i == i3 || i == i2) {
                list.add(ˏ(textView, i3 == i));
                if (i3 == i) {
                    list.add(ॱ(textView));
                }
            }
        }
    }

    private ObjectAnimator ˏ(TextView textView, boolean z) {
        float f = z ? 1.0f : 0.0f;
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(textView, View.ALPHA, new float[]{f});
        ofFloat.setDuration(167);
        ofFloat.setInterpolator(aqv.ˊ);
        return ofFloat;
    }

    private ObjectAnimator ॱ(TextView textView) {
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(textView, View.TRANSLATION_Y, new float[]{-this.ʼ, 0.0f});
        ofFloat.setDuration(217);
        ofFloat.setInterpolator(aqv.ˎ);
        return ofFloat;
    }

    void ˏ() {
        if (this.ʻ != null) {
            this.ʻ.cancel();
        }
    }

    boolean ˏ(int i) {
        return i == 0 || i == 1;
    }

    @Nullable
    private TextView ˋ(int i) {
        switch (i) {
            case 1:
                return this.ˊॱ;
            case 2:
                return this.ᐝॱ;
            default:
                return null;
        }
    }

    public void ॱ() {
        if (ˏॱ()) {
            ViewCompat.ˏ(this.ˎ, ViewCompat.ʻ(this.ˋ.ˎ()), 0, ViewCompat.ᐝ(this.ˋ.ˎ()), 0);
        }
    }

    private boolean ˏॱ() {
        return (this.ˎ == null || this.ˋ.ˎ() == null) ? false : true;
    }

    public void ॱ(TextView textView, int i) {
        if (this.ˎ == null && this.ˊ == null) {
            this.ˎ = new LinearLayout(this.ॱ);
            this.ˎ.setOrientation(0);
            this.ˋ.addView(this.ˎ, -1, -2);
            this.ˊ = new FrameLayout(this.ॱ);
            this.ˎ.addView(this.ˊ, -1, new LayoutParams(-2, -2));
            this.ˎ.addView(new Space(this.ॱ), new LinearLayout.LayoutParams(0, 0, 1.0f));
            if (this.ˋ.ˎ() != null) {
                ॱ();
            }
        }
        if (ˏ(i)) {
            this.ˊ.setVisibility(0);
            this.ˊ.addView(textView);
            this.ॱॱ++;
        } else {
            this.ˎ.addView(textView, i);
        }
        this.ˎ.setVisibility(0);
        this.ˏ++;
    }

    public void ˋ(TextView textView, int i) {
        if (this.ˎ != null) {
            if (!ˏ(i) || this.ˊ == null) {
                this.ˎ.removeView(textView);
            } else {
                this.ॱॱ--;
                ˏ(this.ˊ, this.ॱॱ);
                this.ˊ.removeView(textView);
            }
            this.ˏ--;
            ˏ(this.ˎ, this.ˏ);
        }
    }

    private void ˏ(ViewGroup viewGroup, int i) {
        if (i == 0) {
            viewGroup.setVisibility(8);
        }
    }

    public void ˎ(boolean z) {
        if (this.ˏॱ != z) {
            ˏ();
            if (z) {
                this.ˊॱ = new AppCompatTextView(this.ॱ);
                this.ˊॱ.setId(j.ˊॱ);
                if (this.ʻॱ != null) {
                    this.ˊॱ.setTypeface(this.ʻॱ);
                }
                ॱ(this.ͺ);
                this.ˊॱ.setVisibility(4);
                ViewCompat.ˋ(this.ˊॱ, 1);
                ॱ(this.ˊॱ, 0);
            } else {
                ˎ();
                ˋ(this.ˊॱ, 0);
                this.ˊॱ = null;
                this.ˋ.ʽ();
                this.ˋ.ʼ();
            }
            this.ˏॱ = z;
        }
    }

    public boolean ˋ() {
        return this.ˏॱ;
    }

    public boolean ʻ() {
        return this.ॱˋ;
    }

    public void ˊ(boolean z) {
        if (this.ॱˋ != z) {
            ˏ();
            if (z) {
                this.ᐝॱ = new AppCompatTextView(this.ॱ);
                this.ᐝॱ.setId(j.ॱˊ);
                if (this.ʻॱ != null) {
                    this.ᐝॱ.setTypeface(this.ʻॱ);
                }
                this.ᐝॱ.setVisibility(4);
                ViewCompat.ˋ(this.ᐝॱ, 1);
                ˎ(this.ॱᐝ);
                ॱ(this.ᐝॱ, 1);
            } else {
                ˊ();
                ˋ(this.ᐝॱ, 1);
                this.ᐝॱ = null;
                this.ˋ.ʽ();
                this.ˋ.ʼ();
            }
            this.ॱˋ = z;
        }
    }

    public boolean ʽ() {
        return ˊ(this.ʽ);
    }

    private boolean ˊ(int i) {
        if (i != 1 || this.ˊॱ == null || TextUtils.isEmpty(this.ˋॱ)) {
            return false;
        }
        return true;
    }

    public CharSequence ᐝ() {
        return this.ˋॱ;
    }

    public void ॱ(Typeface typeface) {
        if (typeface != this.ʻॱ) {
            this.ʻॱ = typeface;
            ॱ(this.ˊॱ, typeface);
            ॱ(this.ᐝॱ, typeface);
        }
    }

    private void ॱ(@Nullable TextView textView, Typeface typeface) {
        if (textView != null) {
            textView.setTypeface(typeface);
        }
    }

    @ColorInt
    public int ॱॱ() {
        return this.ˊॱ != null ? this.ˊॱ.getCurrentTextColor() : -1;
    }

    @Nullable
    public ColorStateList ʼ() {
        return this.ˊॱ != null ? this.ˊॱ.getTextColors() : null;
    }

    public void ˏ(@Nullable ColorStateList colorStateList) {
        if (this.ˊॱ != null) {
            this.ˊॱ.setTextColor(colorStateList);
        }
    }

    public void ॱ(@StyleRes int i) {
        this.ͺ = i;
        if (this.ˊॱ != null) {
            this.ˋ.ˊ(this.ˊॱ, i);
        }
    }

    public void ॱ(@Nullable ColorStateList colorStateList) {
        if (this.ᐝॱ != null) {
            this.ᐝॱ.setTextColor(colorStateList);
        }
    }

    public void ˎ(@StyleRes int i) {
        this.ॱᐝ = i;
        if (this.ᐝॱ != null) {
            TextViewCompat.ˎ(this.ᐝॱ, i);
        }
    }
}
